<%@Page Language="VB" debug="true"%>
<%@Import Namespace="System.Drawing" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<script language="JScript">
<!--
function ShowHTMLContent() {
  var strURL = 'http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>?<% = Request.QueryString %>';
  var strDisplay = new String;
  var objHTTP = new ActiveXObject("microsoft.XMLHTTP")
  objHTTP.open('GET', strURL, false);
  objHTTP.send();
  var strReply = objHTTP.responseText;
  var intStart = strReply.indexOf('<!' + '--start-->') + 12;
  var intEnd = strReply.indexOf('<!' + '--end-->');
  if ((intStart > 0) && (intEnd > intStart))
    var strDisplay = strReply.substring(intStart, intEnd);
  document.all['outHTML'].innerText = strDisplay + ' ';
}
function SetCheck(strCheckboxName) {
  document.all[strCheckboxName].checked = true;
}
//-->
</script>

<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff" onload="ShowHTMLContent()">
<!--------------------------------------------------------------------------->
<span class="heading">ASP:CheckBoxList Control</span><p />

<!--start-->
<ASP:CheckBoxList id="MyControl" runat="server" />
<!--end-->

<p />
<div id="outError" runat="server" />
<font face="Courier New" size="2"><div style="background-color:gainsboro; padding-left:10px" id="outHTML">Fetching HTML content...</div></font>

<form runat="server" method="get">
<table border="0">
<tr><td nowrap="nowrap"><input type="checkbox" id="chkAutoPostBack" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">AutoPostBack =</td><td nowrap="nowrap"><select id="selAutoPostBack" size="1" runat="server" onchange="SetCheck('chkAutoPostBack')"><option>True</option><option>False</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp;</td>
<td nowrap="nowrap"><input type="checkbox" id="chkBackColor" runat="server" /> Set: &nbsp;</td><td align="right" nowrap="nowrap">BackColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBackColor" runat="server" onkeypress="SetCheck('chkBackColor')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBorderColor" runat="server" onkeypress="SetCheck('chkBorderColor')" /></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderStyle" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderStyle =</td><td nowrap="nowrap"><select id="selBorderStyle" size="1" runat="server" onchange="SetCheck('chkBorderStyle')">
<option value="4">BorderStyle.Solid</option><option value="3">BorderStyle.Dashed</option><option value="2">BorderStyle.Dotted</option><option value="5">BorderStyle.Double</option>
<option value="6">BorderStyle.Groove</option><option value="8">BorderStyle.Inset</option><option value="1">BorderStyle.None</option><option value="0">BorderStyle.NotSet</option>
<option value="9">BorderStyle.Outset</option><option value="7">BorderStyle.Ridge</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderWidth =</td><td nowrap="nowrap"><input type="text" size="2" id="txtBorderWidth" runat="server" onkeypress="SetCheck('chkBorderWidth')" />px</td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkCellPadding" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellPadding =</td><td nowrap="nowrap"><input type="text" size="2" id="txtCellPadding" runat="server" onkeypress="SetCheck('chkCellPadding')" />px</td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkCellSpacing" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellSpacing =</td><td nowrap="nowrap"><input type="text" size="2" id="txtCellSpacing" runat="server" onkeypress="SetCheck('chkCellSpacing')" />px</td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkDataTextField" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">DataTextField =</td><td nowrap="nowrap"><select id="selDataTextField" size="1" runat="server" onchange="SetCheck('chkDataTextField')"><option>Key</option><option>Value</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkDataTextFormatString" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">DataTextFormatString =</td><td nowrap="nowrap"><input type="text" size="15" id="txtDataTextFormatString" runat="server" onkeypress="SetCheck('chkDataTextFormatString')" /></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkDataValueField" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">DataValueField =</td><td nowrap="nowrap"><select id="selDataValueField" size="1" runat="server" onchange="SetCheck('chkDataValueField')"><option>Key</option><option>Value</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkEnabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Enabled =</td><td nowrap="nowrap"><select id="selEnabled" size="1" runat="server" onchange="SetCheck('chkEnabled')"><option>True</option><option>False</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkForeColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ForeColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtForeColor" runat="server" onkeypress="SetCheck('chkForeColor')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkHeight" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Height =</td><td nowrap="nowrap"><input type="text" size="2" id="txtHeight" runat="server" onkeypress="SetCheck('chkHeight')" />px</td><td nowrap="nowrap"></td>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">ID =</td><td nowrap="nowrap"><% = MyControl.ID %></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkRepeatColumns" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">RepeatColumns =</td><td nowrap="nowrap"><input type="text" size="2" id="txtRepeatColumns" runat="server" onkeypress="SetCheck('chkRepeatColumns')" /></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkRepeatDirection" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">RepeatDirection =</td><td nowrap="nowrap"><select id="selRepeatDirection" size="1" runat="server" onchange="SetCheck('chkRepeatDirection')">
<option value="0">RepeatDirection.Horizontal</option><option value="1">RepeatDirection.Vertical</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkRepeatLayout" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">RepeatLayout =</td><td nowrap="nowrap"><select id="selRepeatLayout" size="1" runat="server" onchange="SetCheck('chkRepeatLayout')">
<option value="1">RepeatLayout.Flow</option><option value="0">RepeatLayout.Table</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkSelectedIndex" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">SelectedIndex =</td><td nowrap="nowrap"><select id="selSelectedIndex" size="1" runat="server" onchange="SetCheck('chkSelectedIndex')">
<option>-1</option><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkTextAlign" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">TextAlign =</td><td nowrap="nowrap"><select id="selTextAlign" size="1" runat="server" onchange="SetCheck('chkTextAlign')">
<option value="1">TextAlign.Left</option><option value="2">TextAlign.Right</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkToolTip" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ToolTip =</td><td nowrap="nowrap"><input type="text" size="20" id="txtToolTip" runat="server"  onkeypress="SetCheck('chkToolTip')"/></td><td nowrap="nowrap"></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selVisible" size="1" runat="server" onchange="SetCheck('chkVisible')"><option>True</option><option>False</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Width =</td><td nowrap="nowrap"><input type="text" size="2" id="txtWidth" runat="server" onkeypress="SetCheck('chkWidth')" />px</td>
</tr><tr>
<td nowrap="nowrap"></td><td nowrap="nowrap"></td><td nowrap="nowrap"></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="button" Value="Reset" onclick="javascript:location.href='http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>'"></td><td nowrap="nowrap"></td><td nowrap="nowrap"><input type="submit" Value="Update" runat="server" /></td></tr>
</table>
</form>

<script language="VB" runat="server">
Sub Page_Load()

outError.innerHTML = ""

Try

   Dim tabValues As New HashTable(5)
   tabValues.Add("Microsoft", 49.56)
   tabValues.Add("Sun", 28.33)
   tabValues.Add("IBM", 55)
   tabValues.Add("Compaq", 20.74)
   tabValues.Add("Oracle", 41.1)
   MyControl.DataSource = tabValues

   If IsPostBack() Then

      If chkDataValueField.Checked Then MyControl.DataValueField = selDataValueField.Value
      If chkDataTextFormatString.Checked Then MyControl.DataTextFormatString = txtDataTextFormatString.Value
      If chkDataTextField.Checked Then MyControl.DataTextField = selDataTextField.Value
      MyControl.DataBind()
      If chkAutoPostBack.Checked Then MyControl.AutoPostBack = selAutoPostBack.Value
      If chkBackColor.Checked Then MyControl.BackColor = Color.FromName(txtBackColor.Value)
      If chkBorderColor.Checked Then MyControl.BorderColor = Color.FromName(txtBorderColor.Value)
      If chkBorderStyle.Checked Then MyControl.BorderStyle = selBorderStyle.Value
      If chkBorderWidth.Checked Then MyControl.BorderWidth = Unit.Pixel(txtBorderWidth.Value)
      If chkCellPadding.Checked Then MyControl.CellPadding = txtCellPadding.Value
      If chkCellSpacing.Checked Then MyControl.CellSpacing = txtCellSpacing.Value
      If chkEnabled.Checked Then MyControl.Enabled = selEnabled.Value
      If chkForeColor.Checked Then MyControl.ForeColor = Color.FromName(txtForeColor.Value)
      If chkHeight.Checked Then MyControl.Height = Unit.Pixel(txtHeight.Value)
      If chkRepeatColumns.Checked Then MyControl.RepeatColumns = txtRepeatColumns.Value
      If chkRepeatDirection.Checked Then MyControl.RepeatDirection = selRepeatDirection.Value
      If chkRepeatLayout.Checked Then MyControl.RepeatLayout = selRepeatLayout.Value
      If chkSelectedIndex.Checked Then MyControl.SelectedIndex = selSelectedIndex.Value
      If chkTextAlign.Checked Then MyControl.TextAlign = selTextAlign.Value
      If chkToolTip.Checked Then MyControl.ToolTip = txtToolTip.Value
      If chkVisible.Checked Then MyControl.Visible = selVisible.Value
      If chkWidth.Checked Then MyControl.Width = Unit.Pixel(txtWidth.Value)

   Else

      MyControl.DataValueField = "Value"
      MyControl.DataTextField = "Key"
      MyControl.DataBind()

   End If

   selAutoPostBack.Value = MyControl.AutoPostBack
   txtBackColor.Value = MyControl.BackColor.Name
   txtBorderColor.Value = MyControl.BorderColor.Name
   selBorderStyle.Value = MyControl.BorderStyle
   txtBorderWidth.Value = MyControl.BorderWidth.Value
   txtCellPadding.Value = MyControl.CellPadding
   txtCellSpacing.Value = MyControl.CellSpacing
   selDataValueField.Value = MyControl.DataValueField
   txtDataTextFormatString.Value = MyControl.DataTextFormatString
   selDataTextField.Value = MyControl.DataTextField
   selEnabled.Value = MyControl.Enabled
   txtForeColor.Value = MyControl.ForeColor.Name
   txtHeight.Value = MyControl.Height.Value
   txtRepeatColumns.Value = MyControl.RepeatColumns
   selRepeatDirection.Value = MyControl.RepeatDirection
   selRepeatLayout.Value = MyControl.RepeatLayout
   selSelectedIndex.Value = MyControl.SelectedIndex
   selTextAlign.Value = MyControl.TextAlign
   txtToolTip.Value = MyControl.ToolTip
   selVisible.Value = MyControl.Visible
   txtWidth.Value = MyControl.Width.Value

Catch objError As Exception

   outError.innerHTML = "<b>* Error</b>: " & objError.Message & "<p />"

End Try

End Sub
</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>
